package com.cpkso.buss.backend.trade.dao;

import java.util.Date;
import java.util.List;

//import org.hibernate.dialect.function.TrimFunctionTemplate.Specification;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.cpkso.buss.backend.trade.domain.TbOrder;
import com.cpkso.buss.backend.trade.vo.StatisticsConditionVo;
import com.cpkso.buss.backend.trade.vo.StatisticsListVo;

/**
 * @author wrzhxy@qq.com
 * @date 2018年5月9日
 */
@Repository
public interface TbOrderDao extends PagingAndSortingRepository<TbOrder, Long>, JpaSpecificationExecutor<TbOrder>, StatisticationDao {

	TbOrder findOneBySellerOrderId(String sellerOrderId);
	List<TbOrder> findBySellerTimeBetweenAndSellerOrderIdNotIn(Date orderStartTime, Date orderEndTime, String[] sellerOrderIds);
	List<TbOrder> findByBuyerTimeBetweenAndBuyerOrderIdNotIn(Date orderStartTime, Date orderEndTime, String[] buyerOrderIds);
	
	@Override
	List<TbOrder> findAll();
	// 查询 总差价，公司总收入
	// 若不想用存储过程则主管非主管必须用0.55 和0.5表示
//	@Query("select new com.cpkso.buss.backend.trade.vo.StatisticsListVo(sum(sellerPrice - buyerPrice), sum((sellerPrice - buyerPrice) * user.charge)) from TbOrder")
	@Override
	StatisticsListVo bedeprive(StatisticsConditionVo scv);
}
